package com.school.system.repository;

import com.school.system.entity.SchoolClass;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 班级Repository接口
 * 
 * @author 鹿与兔
 * @since 2025-05-22
 */
@Repository
public interface SchoolClassRepository extends JpaRepository<SchoolClass, Long> {

    /**
     * 根据班级名称查找班级
     */
    SchoolClass findByClassName(String className);

    /**
     * 根据年级查找班级列表
     */
    List<SchoolClass> findByGrade(String grade);

    /**
     * 根据专业查找班级列表
     */
    List<SchoolClass> findByMajor(String major);

    /**
     * 根据班级名称模糊查询
     */
    @Query("SELECT c FROM SchoolClass c WHERE c.className LIKE %:className%")
    List<SchoolClass> findByClassNameContaining(@Param("className") String className);
}
